home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15715 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: ix.netcom.com!news
  2. From: philma@ix.netcom.com(Phil Majtan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How do the functions in <time.h> work?
  5. Date: 20 Apr 1996 21:54:22 GMT
  6. Organization: Netcom
  7. Message-ID: <4lbmee$hrg@dfw-ixnews1.ix.netcom.com>
  8. References: <317653DA.5066@ix.netcom.com>
  9. NNTP-Posting-Host: det-mi4-18.ix.netcom.com
  10. X-NETCOM-Date: Sat Apr 20  4:54:22 PM CDT 1996
  11.  
  12. In <317653DA.5066@ix.netcom.com> Jane Harper <jharper@ix.netcom.com>
  13. writes: 
  14. >
  15. >This is sort of a homework question, so flame away if you must ...
  16. >
  17. >...but I'm attempting to write a bit of code to access the system time
  18.  
  19. >and when I call ctime() it returns January, 2014 (!!!!)  How does
  20. ctime 
  21. >work (or any of the fx in <time.h> for that matter, since they're all 
  22. >connected)?  What are some possible reasons for this bogus return?
  23. >
  24. >TIA
  25. >
  26. >Jane Harper
  27.  
  28. In my compiler (BCC), the ctime function is passed a pointer to a
  29. time_t variable.  If you are passing it someting else, it may be
  30. interpreting garbage.  It may not be getting a pointer...
  31. Try something like:
  32.  
  33. {
  34.   time_t  timevar;
  35.  
  36.   {some code to set the time, like time(&timevar) }
  37.  
  38.   printf ("%s",ctime(&timevar));
  39.  
  40. }
  41.  
  42. Phil
  43.  
  44.